<?php
use Webman\Route;

// 前台路由组
Route::group('/app/ky_shouyin', function () {
    // 收银台相关接口
    Route::get('/', [plugin\ky_shouyin\app\controller\front\CashierController::class, 'index']);
    Route::get('/front/cashier/index', [plugin\ky_shouyin\app\controller\front\CashierController::class, 'index']);
    Route::get('/front/cashier/goods', [plugin\ky_shouyin\app\controller\front\CashierController::class, 'getGoods']);
    Route::get('/front/cashier/categories', [plugin\ky_shouyin\app\controller\front\CashierController::class, 'categories']);
    Route::get('/front/cashier/get-member', [plugin\ky_shouyin\app\controller\front\CashierController::class, 'getMember']);
    Route::post('/front/cashier/submit-order', [plugin\ky_shouyin\app\controller\front\CashierController::class, 'submitOrder']);
    
    // 会员相关接口
    Route::get('/front/member/index', [plugin\ky_shouyin\app\controller\front\MemberController::class, 'index']);
    Route::get('/front/member/add', [plugin\ky_shouyin\app\controller\front\MemberController::class, 'add']);
    Route::post('/front/member/save', [plugin\ky_shouyin\app\controller\front\MemberController::class, 'save']);
    Route::get('/front/member/get-levels', [plugin\ky_shouyin\app\controller\front\MemberController::class, 'getLevels']);
    Route::get('/front/member/get-stores', [plugin\ky_shouyin\app\controller\front\MemberController::class, 'getStores']);
    Route::get('/front/member/recharge', [plugin\ky_shouyin\app\controller\front\MemberController::class, 'recharge']);
    Route::post('/front/member/do-recharge', [plugin\ky_shouyin\app\controller\front\MemberController::class, 'doRecharge']);
});

// 后台路由组
Route::group('/app/ky_shouyin/admin', function () {
    // 后台首页
    Route::get('/', [plugin\ky_shouyin\app\controller\admin\IndexController::class, 'index']);
    
    // 订单管理
    Route::get('/order/index', [plugin\ky_shouyin\app\controller\admin\OrderController::class, 'index']);
    Route::get('/order/list', [plugin\ky_shouyin\app\controller\admin\OrderController::class, 'list']);
    Route::get('/order/detail', [plugin\ky_shouyin\app\controller\admin\OrderController::class, 'detail']);
    Route::get('/order/export', [plugin\ky_shouyin\app\controller\admin\OrderController::class, 'export']);
    Route::post('/order/delete', [plugin\ky_shouyin\app\controller\admin\OrderController::class, 'delete']);
    
    // 会员管理
    Route::get('/member/index', [plugin\ky_shouyin\app\controller\admin\MemberController::class, 'index']);
    Route::get('/member/list', [plugin\ky_shouyin\app\controller\admin\MemberController::class, 'list']);
    Route::get('/member/add', [plugin\ky_shouyin\app\controller\admin\MemberController::class, 'add']);
    Route::post('/member/add', [plugin\ky_shouyin\app\controller\admin\MemberController::class, 'add']);
    Route::get('/member/edit', [plugin\ky_shouyin\app\controller\admin\MemberController::class, 'edit']);
    Route::post('/member/edit', [plugin\ky_shouyin\app\controller\admin\MemberController::class, 'edit']);
    Route::post('/member/delete', [plugin\ky_shouyin\app\controller\admin\MemberController::class, 'delete']);
    
    // 员工管理
    Route::get('/staff/index', [plugin\ky_shouyin\app\controller\admin\StaffController::class, 'index']);
    Route::get('/staff/list', [plugin\ky_shouyin\app\controller\admin\StaffController::class, 'list']);
    Route::get('/staff/add', [plugin\ky_shouyin\app\controller\admin\StaffController::class, 'add']);
    Route::post('/staff/add', [plugin\ky_shouyin\app\controller\admin\StaffController::class, 'add']);
    Route::get('/staff/edit', [plugin\ky_shouyin\app\controller\admin\StaffController::class, 'edit']);
    Route::post('/staff/edit', [plugin\ky_shouyin\app\controller\admin\StaffController::class, 'edit']);
    Route::post('/staff/delete', [plugin\ky_shouyin\app\controller\admin\StaffController::class, 'delete']);
    
    // 交班管理
    Route::get('/staff/shift', [plugin\ky_shouyin\app\controller\admin\StaffController::class, 'shift']);
    Route::get('/staff/current-shift', [plugin\ky_shouyin\app\controller\admin\StaffController::class, 'currentShift']);
    Route::get('/staff/shift-list', [plugin\ky_shouyin\app\controller\admin\StaffController::class, 'shiftList']);
    Route::post('/staff/end-shift', [plugin\ky_shouyin\app\controller\admin\StaffController::class, 'endShift']);
    Route::get('/staff/shift-detail', [plugin\ky_shouyin\app\controller\admin\StaffController::class, 'shiftDetail']);
    Route::post('/staff/delete-shift', [plugin\ky_shouyin\app\controller\admin\StaffController::class, 'deleteShift']);
    
    // 统计分析
    Route::get('/statistics/index', [plugin\ky_shouyin\app\controller\admin\StatisticsController::class, 'index']);
    Route::get('/statistics/sales', [plugin\ky_shouyin\app\controller\admin\StatisticsController::class, 'sales']);
    Route::get('/statistics/member', [plugin\ky_shouyin\app\controller\admin\StatisticsController::class, 'member']);
    Route::get('/statistics/payment', [plugin\ky_shouyin\app\controller\admin\StatisticsController::class, 'payment']);
});

// 添加404回退路由
Route::fallback(function(){
    return json(['code' => 404, 'msg' => '404 not found']);
}); 